﻿namespace Common
{
    public class ResultBuilder
    {
        public static Result<T> Success<T>(T data, string message = "请求成功")
        {
            return new Result<T>
            {
                Code = 0,
                Message = message,
                Data = data
            };
        }

        public static Result<T> Fail<T>(T? data, string message = "请求失败", int code = 99)
        {
            return new Result<T>
            {
                Code = code,
                Message = message,
                Data = data
            };
        }

    }

    public class Result<T>
    {
        public Result()
        {
            
        }
        public Result(int code, string message, T data)
        {
            this.Code = code;
            this.Message = message;
            this.Data = data;
        }

        /// <summary>
        /// 响应信息
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 响应状态码
        /// </summary>
        public int Code { get; set; }

        /// <summary>
        /// 响应对象
        /// </summary>
        public T? Data { get; set; }
    }


}
